<template>
	<el-dialog v-model="dialogFormVisible" title="" width="500">
		<el-form :model="form">
			<el-form-item label="生成代码到目录">
				<el-radio-group v-model="form.status">
					<el-radio :value="1">是</el-radio>
					<el-radio :value="2">否</el-radio>
				</el-radio-group>
			</el-form-item>
		</el-form>
		<template #footer>
			<div class="dialog-footer">
				<el-button type="primary" @click="genCode">确定</el-button>
				<el-button @click="dialogFormVisible = false"> 取消 </el-button>
			</div>
		</template>
	</el-dialog>
</template>

<script lang="ts" setup name="confirmGenDialog">
import { reactive, ref } from 'vue'
import { tableApi } from '@/api/sys/table'
import { ElMessage } from 'element-plus'

const dialogFormVisible = ref(false)

const form = reactive({
	status: 2,
	id: 0
})

const openDialog = (id: number) => {
	form.id = id
	dialogFormVisible.value = true
}
const emit = defineEmits(['refresh'])
const genCode = () => {
	tableApi.generateCodeApi(form).then((r: any) => {
		ElMessage.success('success')
		dialogFormVisible.value = false
		emit('refresh')
		form.status = 2
	})
}
defineExpose({ openDialog })
</script>
